package crawler.torunski;

import java.io.File;


import crawler.LinkFilterRepository;
import crawler.StatisticsFileWriter;

public class TorunskiCrawlerFactory {
	
	public static final String DEPTH_MODEL = "dep";
	public static final String ITERATION_MODEL = "it";
	
//	public static ITorunskiCrawler trovaCasaCrawler(int maxLinks,  StatisticsFileWriter statisticsWriter, String path){
//		String server = "http://www.trova-casa.net";
//		String start = "/immobili.asp";
//		File file = new File(path+"/trovacase/");
//		statisticsWriter.register(server, maxLinks);
//		LinkFilterRepository repository = new LinkFilterRepository("http://www\\.trova-casa\\.net/annunci/TC-\\d+\\.htm",file,statisticsWriter);
//		return new TorunskiIterationCrawler(server,start,maxLinks,repository);
//	}
	
	public static ITorunskiCrawler immobiliareItCrawler(int maxLinks, String path, String model){
		String server = "http://www.immobiliare.it/";
		String start = "/index.php";
		File file = new File(path+"/immobiliare/");
		StatisticsFileWriter.getInstance().register(server, maxLinks);
		LinkFilterRepository repository = new LinkFilterRepository("http://www\\.immobiliare\\.it/.*\\d-.*\\.html",file);
		if(model.equals(DEPTH_MODEL)) return new TorunskiDepthCrawler(server,start,maxLinks,repository);
		return new TorunskiIterationCrawler(server,start,maxLinks,repository);
	}
	
	public static ITorunskiCrawler bachecacase(int maxLinks, String path, String model){
		String server = "http://www.bachecacase.com/";
		String start = "/index.php";
		File file = new File(path+"/bachecacase/");
		StatisticsFileWriter.getInstance().register(server, maxLinks);
		LinkFilterRepository repository = new LinkFilterRepository("((http://www\\.bachecacase\\.com/.*\\d.html)|(http://www\\.bachecacase\\.com))",file);
		if(model.equals(DEPTH_MODEL)) return new TorunskiDepthCrawler(server,start,maxLinks,repository);
		return new TorunskiIterationCrawler(server,start,maxLinks,repository);
	}

}
